# 计算间隔指定天数的日期
import datetime


def diff_time(base_time, days, hours):
    # 格式化
    b_time = datetime.datetime.strptime(base_time, "%Y-%m-%d %H:%M:%S")
    # 一个时间间隔
    assert_day = datetime.timedelta(days=days, hours=hours)
    target_time = b_time - assert_day
    return target_time.strftime("%Y-%m-%d %H:%M:%S")


print(
    diff_time("2024-06-03 20:00:00", 3, 3),
    diff_time("2024-06-03 20:00:00", 2, 2),
    diff_time("2024-06-03 20:00:00", 1, 1)
)
